package com.cqyc.shop.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cqyc.shop.comm.Pager;
import com.cqyc.shop.comm.commException;
import com.cqyc.shop.domain.Shop;
import com.cqyc.shop.services.ShopServices;

@WebServlet(urlPatterns="/outcome.do")
public class outcomeServlet extends HttpServlet{

	private static final long serialVersionUID = -4499012091964693276L;
	
	private Logger logger = LoggerFactory.getLogger(getClass());
	private ShopServices shopServices = new ShopServices();
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
			try {
				Shop shop = new Shop();
							
				Pager pager_cxjg = new Pager();
				pager_cxjg.setPageSize(12);
				pager_cxjg.setCurrentPage(1);
				String shopname=request.getParameter("shopname");
				shop.setShopname(shopname);
				
				List<Shop> shops_cxjg = shopServices.findPager(shop,pager_cxjg);

				request.setAttribute("shops_cxjg",shops_cxjg);
				
				
				Pager pager_rmtj = new Pager();
				pager_rmtj.setPageSize(3);
				pager_rmtj.setCurrentPage(7);
				shopname=request.getParameter("shopname");
				shop.setShopname(shopname);
				
				List<Shop> shops_rmtj = shopServices.findPager(shop,pager_rmtj);

				request.setAttribute("shops_rmtj",shops_rmtj);

				
				logger.debug("查询数据成功");
				request.getRequestDispatcher("/outcome.jsp").forward(request, response);
			} catch (Exception e) {
				throw new commException("list查找出现异常");
			}
	}
	

}
